package com.hluobo.library.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.stereotype.Component;

import com.hluobo.library.dao.impl.BasicDao;
import com.hluobo.library.model.Book;
import com.hluobo.library.service.BookService;

@Component("bookService")
public class BookServiceImpl extends BasicDao implements BookService {

	@Override
	public List<Book> query(JSONObject paraObj) {
		
		List<Book> books = new ArrayList<Book>();

		try {

			String sql = "From Book b where " + paraObj.getString("name")
					+ " like '%" + paraObj.getString("val") + "%'";
			books = em.createQuery(sql).getResultList();

		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return books;
	}


}
